﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:Graph="clr-namespace:Patterns4Net.ArchitectureExplorer.ViewModels.Graph" 
                    xmlns:Diagram="clr-namespace:Patterns4Net.ArchitectureExplorer.Diagram" 
                    xmlns:Graphviz4Net="clr-namespace:Graphviz4Net.WPF.ViewModels;assembly=Graphviz4Net" 
                    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro">

    <ResourceDictionary.MergedDictionaries>                
        <ResourceDictionary Source="TypeInfoView.xaml"/>
        <ResourceDictionary Source="Relations.xaml"/>
        <ResourceDictionary>
            <DataTemplate DataType="{x:Type Graph:VertexViewModel}" x:Key="VertexViewModelTemplate">
                <ContentPresenter Content="{Binding .}" Name="Content" ContentTemplate="{DynamicResource VertexViewModelContentTemplate}">
                </ContentPresenter>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Path=Type}" Value="TypeInfoViewModel">
                        <Setter Property="ContentTemplate" Value="{DynamicResource TypeInfoTemplate}" TargetName="Content"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <DataTemplate DataType="{x:Type Graph:VertexViewModel}" x:Key="VertexViewModelContentTemplate">
                <ContentPresenter Content="{Binding DiagramElement}"/>
            </DataTemplate>

            <DataTemplate DataType="{x:Type Graph:DummyVertexViewModel}">
                <Rectangle Width="5" Height="5"/>
            </DataTemplate>

            <DataTemplate DataType="{x:Type Graph:VertexViewModel}">
                <Button 
                    BorderThickness="1"
                    cal:Action.Target="{Binding}"
                    cal:Message.Attach="[Event Click] = [Action Select]; [Event MouseDoubleClick] = [Action ZoomIn]">
                    <Button.Template>
                        <ControlTemplate>
                            <Border BorderThickness="1" CornerRadius="2.5">
                                <Border.Style>
                                    <Style>
                                        <Style.Triggers>
                                            <Trigger Property="Border.IsMouseOver" Value="True">
                                                <Setter Property="Border.Effect">
                                                    <Setter.Value>
                                                        <DropShadowEffect BlurRadius="2" Color="#BBBBBB" 
		                                                    Opacity="0.3" Direction="315"/>
                                                    </Setter.Value>
                                                </Setter>
                                            </Trigger>
                                        </Style.Triggers>
                                    </Style>
                                </Border.Style>
                                <Grid>
                                    <Rectangle Fill="Transparent"/> <!-- make sure that mouse is always over something -->
                                    <ContentPresenter Content="{Binding .}" ContentTemplate="{DynamicResource VertexViewModelTemplate}"/>
                                </Grid>
                            </Border>
                        </ControlTemplate>
                    </Button.Template>
                </Button>
            </DataTemplate>


                <!-- This is just template for package when it is rendered as part of a layer, without any children -->
            <DataTemplate DataType="{x:Type Diagram:Package}">
                <Border BorderBrush="Black" BorderThickness="1" Background="White"
                        CornerRadius="1" Padding="10, 5, 10, 5">
                    <TextBlock Text="{Binding Path=Name}"/>
                </Border>
            </DataTemplate>

            <!-- This is template for all sub-graphs -->
            <DataTemplate DataType="{x:Type Graph:SubGraphViewModel}">
                <Button                    
                    cal:Action.Target="{Binding}"
                    cal:Message.Attach="[Event Click] = [Action Select]; [Event MouseDoubleClick] = [Action ZoomIn]">
                    <Button.Template>
                        <ControlTemplate>
                            <Border BorderBrush="Black"
                                CornerRadius="1"
                                BorderThickness="1"
                                Background="White"
                                Padding="10, 0, 0, 0">
                                <Border.Style>
                                    <Style>
                                        <Style.Triggers>
                                            <Trigger Property="Border.IsMouseOver" Value="True">
                                                <Setter Property="Border.Effect">
                                                    <Setter.Value>
                                                        <DropShadowEffect BlurRadius="3" Color="LightGray" 
		                                                    Opacity="0.3" Direction="315"/>
                                                    </Setter.Value>
                                                </Setter>
                                            </Trigger>
                                            <Trigger Property="Border.IsMouseOver" Value="False">
                                                <Setter Property="Border.Effect">
                                                    <Setter.Value>
                                                        <DropShadowEffect BlurRadius="3" Color="White" 
		                                                    Opacity="0.3" Direction="315"/>
                                                    </Setter.Value>
                                                </Setter>
                                            </Trigger>                                            
                                        </Style.Triggers>
                                    </Style>
                                </Border.Style>
                                <TextBlock Text="{Binding Path=Label}"/>
                            </Border>
                        </ControlTemplate>
                    </Button.Template>
                </Button>
            </DataTemplate>
            
            <DataTemplate DataType="{x:Type Graphviz4Net:BorderViewModel}">
                <ContentPresenter Content="{Binding SubGraph}"/>
            </DataTemplate>           

            <DataTemplate DataType="{x:Type Graphviz4Net:EdgeLabelViewModel}">
                <TextBlock Text="{Binding Path=Label}"/>
            </DataTemplate>

            <DataTemplate DataType="{x:Type Graphviz4Net:EdgeArrowLabelViewModel}">
                <TextBlock Text="{Binding Path=Label}"/>
            </DataTemplate>
        </ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>